
$(function () {
    if ($.cookie("exist", { name: 'dateCookie' })) {
        var dateCookie = $.cookie("get", {
            name: 'dateCookie'
        }).replace(/\//g, '-')
        var startDate = dateCookie.substr(0, 10)
        var endDate = dateCookie.substr(10)
        var startMonth = startDate.substr(5, 2)
        var startDay = startDate.substr(8, 2)
        var endMonth = endDate.substr(5, 2)
        var endDay = endDate.substr(8, 2)
  
        $('#h5_date .start_date').html(startMonth + '月' + startDay + '日').attr('data-time', startDate)
        $('#h5_date #s_ArrDate').val(startDate)
        $('#h5_date .end_date').html(endMonth + '月' + endDay + '日').attr('data-time', endDate)
        $('#h5_date #s_DepDate').val(endDate)

    }

    if ($("#ForHighLevel").val() == "True") {
        //高星酒店才记录事件
        //酒店名称（页面级变量）
        //酒店详情页面加载时
        if ($("#hotelName_pVar").size() > 0) {
            gio("page.set", { "hotelName_pVar": $("#hotelName_pVar").val() })
            //hotelName_pVar:酒店名称

            //酒店ID（页面级变量）
            //酒店详情页面加载时
            gio("page.set", { "hotelID_pVar": $("#hotelID_pVar").val() })
            //hotelID_pVar:酒店ID

            //酒店所在城市（页面级变量）
            //酒店详情页面加载时
            gio("page.set", { "hotelCity_pVar": $("#hotelCity_pVar").val() })
            //hotelCity_pVar:酒店所在城市

            //酒店一级分类
            //酒店详情页面加载时
            gio("page.set", { "hotelPrimaryCategory_pVar": $("#hotelPrimaryCategory_pVar").val() })
            //hotelPrimaryCategory_pVar: 区分中高端,高端,低端等

            //酒店二级分类
            //酒店详情页面加载时
            gio("page.set", { "hotelSecondaryCategory_pVar": $("#hotelSecondaryCategory_pVar").val() })
            //hotelSecondaryCategory_pVar:区分品牌如：如家金牌，如家等

            //总库存 SKU 数
            //酒店详情页面加载时
            gio("page.set", { "hotelTotalSKU_pVar": $("#hotelTotalSKU_pVar").val() })
            //hotelTotalSKU_pVar：此酒店库总房型数
        }



        //有库存数 SKU 数
        //酒店详情页面加载时
        gio("page.set", { "hotelAvailableSKU_pVar": $("#hotelAvailableSKU_pVar").val() })
    }
 
    var direction = 'right';
    if($('.h5_top_bom p').width() >= $('body').width()){
        (function () {
        var css = {
            'left': '0'
        };
        if (direction === 'right') {
            direction = 'left';
            css.left = $('.h5_top_bom .hidden').width()-$('body').width()-36;
        }
        else {
            direction = 'right';
            $('.h5_top_bom p').css("left","0")
        }
        $('.h5_top_bom p').animate(css, 3000, arguments.callee);

        })();
    } else if ($('.h5_top_bom p').width() < $('body').width() && $('.h5_top_bom p').width() > $('.h5_top_bom .hidden').width()){
    (function () {
        var css = {
            'left': '0'
        };
        if (direction === 'right') {
            direction = 'left';
            css.left =$('.h5_top_bom .hidden').width() - $('body').width();
        }
        else {
            direction = 'right';
            $('.h5_top_bom p').css("left", "0")
        }
        $('.h5_top_bom p').animate(css, 3000, arguments.callee);

    })();
}
    $('.main_pc').css('display', 'none');
    $('#h5Main').css('display', 'none');
    $('.h5_hotelDetial').css('opacity',1);
    $('#h5_mask').show();
    loading_hide()//loading图隐藏;
  
   
    $('.h5_top_bom a,.h5_grade a,.h5_mark a ').click(function () {
        $('#h5_mask').show();      
        loading_hide()//loading图隐藏;
    })
    //解决在假移动刷新页面时pc会一闪而过;
    if (($.browser.msie && $.browser.version > 6) || window.navigator.userAgent.indexOf('rv') > 1) {

    } else {
        //$('body').css({ 'opacity': '1', 'filter': 'alpha(opacity=100)' });
    }

    

    //刷新页面判断视图宽度，加载不同页面   
    
    viewWidth();
    $(window).resize(function () {
        viewWidth();           
    });
   
    
    /*==============================================================详情页信息================================*/
  
        
    //轮播图不存在使用默认图片;
    var banner_arr = [];
    $('.swiper-container .swiper-wrapper img').each(function (i, elem) {
        banner_arr.push($('.swiper-container .swiper-wrapper img').attr('src'))
    });
    error_img($('.swiper-container .swiper-wrapper img'), banner_arr)
   
    $(".list_intro_map_h5").click(function () {
        $("#key").val('H' + $(this).data("hotelcd"));
        $("#keyDescript").val($(this).data("hotelnm"));
        $("#cityName").val($(this).data("city"));
        $("#frm").attr("action", "/map/" + $(this).data("city"));
        $("#frm").submit();
        return false;
    });
      
    //$("#map_h5_box").click(function () {
    //    if ($('#map_h5_box span').hasClass('shouqi')) {
    //        $('#map_h5_box span').removeClass('shouqi')
    //        $('#h5_map_wrap').css({
    //            marginTop: $('.list_intro_map_h5').height() / 2 - 6,
    //        })
    //    } else {
    //        $('#map_h5_box span').addClass('shouqi')
    //         $('#h5_map_wrap').css({
    //             marginTop: $('.list_intro_map_h5').height() / 2 - 6,
    //         })
    //    }
    //});

    //打电话浮层显示
    $('.h5_details .h5_tel').click(function () {
        $('.h5_tel_a').css("display", "block");
        $('.h5_tel_pub').css("display", "block");
    });

    //打电话浮层隐藏;
    $('.h5_tel_a').click(function () {
        $('.h5_tel_a').css("display", "none");
        $('.h5_tel_pub').css("display", "none");
        $('.h5_tel_pub a').css('background', '');
    });

    //改变点击部分背景颜色
    $('.h5_tel_pub a').click(function () {
        $(this).css('background', '#F8E8E8');
    });

    //收藏
    if ($(".list_intro_collect_a").find("strong").html() == "收藏") {
        $('.h5_lic').css({
            'background': '#000',
            'opacity': 0.3,
            'filter': 'alpha(opacity=30)',
        });
    } else {
        $('.h5_lic').css({
            'background': '#C0191F',
            'opacity': 1,
            'filter': 'alpha(opacity=100)',
        });
    }

    $(".list_intro_collect_a").click(function () {
        var hotelCd = $(this).attr("hotelCd");
        var login_mk = $(this).data("login_mk");
        var This = this
        if (login_mk == "") {
            $('.h5_alert_logo').css('display', 'block');
            $('.h5_logo_alert').show();
            //点击取消按钮关闭登录弹框
            $('.login_tk_buttonR_a').click(function () {
                $('.h5_alert_logo').css('display', 'none');
                $('.h5_logo_alert').hide();
            });

            //点击浮层关闭登录弹框
            $('.h5_alert_logo').click(function () {
                $('.h5_alert_logo').css('display', 'none');
                $('.h5_logo_alert').hide();
            })
        } else {
            if ($(this).find("strong").html() == "收藏") {
                $.ajax({
                    type: "GET",
                    url: "/Ajax/CollectHotel_Add",
                    data: { hotelCd: hotelCd, ts: Math.random() },
                    dataType: "json",
                    success: function (result) {
                        if (result != null && result.Code == "200") {
                           $('#h5_mask').hide();
                            $(This).find("strong").html("已收藏");
                            $(This).find("strong").css("color", "#C0191F")
                            $(This).find("span").css("color", "#C0191F")
                            $(This).find("span").html("&#xe60c;");
                            $('.h5_lic').css({
                                'background': '#C0191F',
                                'opacity': 1,
                                'filter': 'alpha(opacity=100)',
                            });
                        }
                    }
                });
            } else {
                $.ajax({
                    type: "GET",
                    url: "/Ajax/CollectHotel_Cancel",
                    data: { hotelCd: hotelCd, ts: Math.random() },
                    dataType: "json",
                    success: function (result) {
                        if (result != null && result.Code == "200") {
                            $('#h5_mask').hide();
                            $(This).find("strong").html("收藏");
                            $(This).find("span").html("&#xe60d;")
                            $(This).find("span").css("color", "#979797");
                            $(This).find("strong").css("color", "#979797");
                            $('.h5_lic').css({
                                'background': '#000',
                                'opacity': 0.3,
                                'filter': 'alpha(opacity=30)',
                            });
                        }
                    }
                });
            }

        }
    });

    //迪士尼直通车显示隐藏
    if ($('.h5_hotelDetial .h5_text .h5_fl').children().length == 0) {
        $(".h5_hotelDetial .h5_stance").css('display', "block");
        $('.h5_hotelDetial .h5_text').css('display', "none");
    } else {
        $(".h5_hotelDetial .h5_stance").css('display', "none");
        $('.h5_hotelDetial .h5_text').css('display', "block");
    }

    //房型信息数据请求
    if ($('#scroller').prop('className') == "") {
        loadRoomTypeList_h5()
    } 
    

    //当查看地图这一块的第一个审判不存在时，让第二个span的宽度变宽
    $('#h5_map_wrap').css({
       // marginTop: ($('.list_intro_map_h5').height() + $('.arrow_down').height()) / 2 - 6,
       marginTop: $('.list_intro_map_h5').height() / 2 - 6,
    })
    
    /*==============================================================/详情页信息================================*/


    /*==============================================================图片情页信息================================*/
     //图片懒加载
    var aImg_detial = $('.h5_hotelImg .h5_img li'); 
        aImgLoad_detial()
        $('.h5_hotelImg').on("scroll", aImgLoad_detial);
        function aImgLoad_detial() {
            aImg_detial.each(function (index, element) {
                var scrollTop = $('.h5_hotelImg').scrollTop();
                var clientH = $('.h5_hotelImg').height();
                var Dom_H = $(element).height();
                var num_ab = Math.ceil((index+1)/ 2);
                var imgTop = Dom_H * num_ab;
                if (scrollTop + clientH > imgTop) {                   
                    $(element).find('img').attr("src", $(element).find('img').attr("_src"));
                }
            })
        };
    //给奇数图片添加类名
    $('.h5_hotelImg .h5_img ul li:even').addClass('li_a');

   //判断导航是不是应该存在
    $('.h5_hotelImg .h5_img ul li').each(function (i, elem) {
        if ($(this).attr('data-isroom') == 1) {
            $('.h5_hotelImg .h5_nav').css('display', 'block');
        } else {
            $('.h5_hotelImg .h5_nav').css('display', 'none');
        }
    })

    //图片不存在使用默认图片
    var arr_src = [];
    $('.h5_hotelImg .h5_img ul li').each(function (i, elem) {
        arr_src.push($('.h5_hotelImg .h5_img ul li').eq(i).find("img").attr('src'))
    });   
    error_img($('.h5_box .h5_img ul img'), arr_src);

    //点击图片导航显示相应的内容;
    $('.h5_hotelImg .h5_nav li').eq(0).click(function () {
        $(".h5_nav li").eq($(this).index()).addClass("h5_active").siblings().removeClass('h5_active');
        $('.h5_hotelImg .h5_img ul li').each(function (i, elem) {
            $(this).css('display', 'block');

        })
    });
    $('.h5_hotelImg .h5_nav li').eq(1).click(function () {
        $(".h5_nav li").eq($(this).index()).addClass("h5_active").siblings().removeClass('h5_active');
        $('.h5_hotelImg .h5_img ul li').each(function (i, elem) {
            if ($(this).attr('data-isroom') == 1) {
                $(this).css('display', 'none');
            } else {
                $(this).find('img').attr('src', $(this).find('img').attr('_src'))
                $(this).css('display', 'block');
            }
        })
    });
    $('.h5_hotelImg .h5_nav li').eq(2).click(function () {
        $(".h5_nav li").eq($(this).index()).addClass("h5_active").siblings().removeClass('h5_active');
        $('.h5_hotelImg .h5_img ul li').each(function (i, elem) {
            if ($(this).attr('data-isroom') == 1) {
                $(this).find('img').attr('src', $(this).find('img').attr('_src'))
                $(this).css('display', 'block');
            } else {
                $(this).css('display', 'none');
            }
        })
    });

    //图片弹框
    var oSrc = null;
    var oIndex = null;
    $('.h5_hotelImg .h5_img ul li').click(function () {
        $('#wrapper').hide();
        oIndex = $(this).index();
        $('.head_num .sm_num').html(oIndex + 1);
        var img_len = $('.h5_box ul li').length;
        var oDiv = $('<div class="swiper-container"><div class="swiper-wrapper"></div></div>');
        $('.h5_alert').append(oDiv);
        for (var i = 0; i < arr_src.length; i++) {
            img_s = $('<div class="swiper-slide"><img src="' + arr_src[i] + '" alt="banner"></div>')
            $('.h5_alert .swiper-wrapper').append(img_s);
        };
        $('.h5_alert .swiper-wrapper').append('<div class="swiper-pagination"></div>');
        $('.h5_alert').css("display", "block");
        //为了兼容ie8图片不居中; 
        //判断ie8
        var isIE = !!window.ActiveXObject;      
        var isIE8 = isIE && !!document.documentMode;
        //判断ie9
        var userAgent = window.navigator.userAgent.toLowerCase();
        $.browser.msie9 = $.browser.msie && /msie 9\.0/i.test(userAgent);
        //  alert(isIE8);
        if (isIE8 || $.browser.msie9) {
            var window_H = $(window).outerHeight();
            $('.h5_alert img').each(function (i, elem) {
                var img_H = $(this).height();
                $(this).css({ "paddingTop": (window_H - img_H) / 2 })
            });
            $(window).resize(function () {
                var window_H = $(window).outerHeight();
                $('.h5_alert img').each(function (i, elem) {
                    var img_H = $(this).height();
                    $(this).css({ "paddingTop": (window_H - img_H) / 2 })
                });
            })
        }
       
        var swiper = new Swiper('.swiper-container', {
            pagination: '.swiper-pagination',
            paginationType: 'fraction',
            initialSlide: oIndex,
            grabCursor: true,
            onSlideChangeStart: function (swiper) {
                $('.head_num .sm_num').html(swiper.activeIndex + 1);
                $('.head_num .bg_num').html('/' + img_len);
                // alert(swiper.activeIndex);
            }

        });
        //关闭弹框;
        $('.h5_alert>span').click(function () {
            /*$(this).css('color','#C0191F')*/
            $('.h5_alert').css("display", "none");
            // $('#wrapper').css({ "overflow": "auto" });
            $('.h5_alert .swiper-container').remove();
            $('#wrapper').show();
        })
    });
    $('.head_num .bg_num').html('/' + $('.h5_img ul li').length);

    ///*==============================================================/图片详情页信息================================*/
    /*==============================================================用户点评================================*/
    //酒店隐藏所有酒店回复;
    $('.user_h5 .h5_hotel_list li').each(function (index, elem) {
        $(elem).find('.user_com').hide();
    });
    //点击酒店回复显示隐藏;
    $("#thelist").delegate(".examine_com", "click", function () {
        if ($(this).parent().find(".user_com").css('display') == 'none') {
            $(this).find('.iconfont').html('&#xe6b3;');
            $(this).find('.h5_reply').html('收起酒店回复');
            $(this).parent().find(".user_com").show();
        } else {
            $(this).find('.iconfont').html('&#xe6b4;');
            $(this).find('.h5_reply').html('查看酒店回复');
            $(this).parent().find(".user_com").hide();
        }
    });

   //判断是pc端访问还是移动端访问 滑动到底部加载下一页;
    browserRedirect();

    //导航栏切换;
    $('.user_h5 .nav_h5 li').click(function () {
        $(".user_h5 .nav_h5 li").eq($(this).index()).addClass("h5_active").siblings().removeClass('h5_active');
        $('#com_box>div').eq($(this).index()).show().siblings().hide();
        if ($(this).index() == 0) {
            $('.user_h5 .h5_comment_box').show();
        } else {
            $('.user_h5 .h5_comment_box').hide();
        }
    });

    //酒店评论数据;
    if ($('#scroller').prop('className')=='user_h5') {
        loadRecomments_a(1);
        $("#thelist").empty();
    }    
    /*==============================================================/用户点评================================*/
    /*==============================================================服务设施================================*/
    //打电话浮层显示
    $('.h5_header_tel').click(function () {
        $('.h5_tel_a').css("display", "block");
        $('.h5_tel_pub').css("display", "block");
    });

    //动态创建展开收起;
    var show_h5 = $('<li class="fix last_h5"><div class="service_jt_h5 fr"><span>展开</span><code class="iconfont">&#xe665;</code></div></li>')
    $('.h5_fac_list').append(show_h5);
    $('.h5_fac_list li').each(function (i, elem) {
        if ($(elem).find('div').length > 2) {
            $(elem).find('div:gt(1)').hide();
        }
    })

    //点击展开收起
    $('li.last_h5 .service_jt_h5').toggle(function () {
        $('.h5_fac_list li').each(function (i, elem) {
            $(elem).find('div:gt(1)').show();
        });
        $(this).find('span').html('收起');
        $(this).find('code').html('&#xe64b;')
    }, function () {
        $('.h5_fac_list li').each(function (i, elem) {
            if ($(elem).find('div').length > 2) {
                $(elem).find('div:gt(1)').hide();
            };
        });
        $(this).find('span').html('展开');
        $(this).find('code').html('&#xe665;')
    });
    //如果服务设施内容不存在移除展开收起
    if ($('.hotel_box_h5 .h5_lib .h5_fac_list li').length == 1) {
        $('.hotel_box_h5 .h5_lib .h5_fac_list li ').remove()

    }

    /*==============================================================/服务设施================================*/
    /*==============================================================日期控件================================*/

    //记录列表页日期
    var s_ArrDate_a = $(".h5_details .start_date").attr("data-time");//入店时间
    var s_DepDate_a = $(".h5_details .end_date").attr("data-time");//离店时间
    var days_a = DateDiffH5(s_ArrDate_a, s_DepDate_a);
    $(".enter_time .total").html(days_a);
    //开始日期跟结束日期相差天数
    function DateDiffH5(startDate, endDate) {
        if (!startDate) {
            return;
        }
        var d1 = new Date(startDate.replace(/-/g, "/"));
        var d2 = new Date(endDate.replace(/-/g, "/"));
        var time = d2.getTime() - d1.getTime();
        return parseInt(time / (1000 * 60 * 60 * 24));
    };
    var today = new Date(),
        todayY = today.getFullYear(),
        todayM = today.getMonth() + 1 < 10 ? "0" + (today.getMonth() + 1) : (today.getMonth() + 1),
        todayD = today.getDate() < 10 ? "0" + today.getDate() : today.getDate();
    /*入住时间日历*/
   
    $('.enter_time').click(function () {
        var maxDays1 = 0;
        if ($("#ForHighLevel").val() == "False") {
            maxDays1 = 90;
        } else {
            maxDays1 = 365;
        }     
        $('.enter_time').dateChoose({
                dateClass: ".date_box_choose",//日期选择页面
                startClass: ".start_date", //开始日期的class
                endClass: ".end_date", //结束日期
                range: true, //开始日期和结束日期都包括，若为false，则只有开始日期
                divideChoose: false,//结束日期和开始日期是否在两个不同的输入框
                startTxt: "入住", //开始日期选中之后出现的文字
                endTxt: "离住",//开始日期选中之后出现的文字
                startDate: todayY + "-" + todayM + "-" + todayD, //日期之后可选
                endDate: "", //日期之前可选

                maxDays: maxDays1,  //之后可点击最大天数,
                Seperate: [],//间隔的日期
                En: false, //是否英文
      
                callback: function () { //日期选中之后的callback  
                    $('.date_box_choose ').animate({ "left": 200+"%" }, 500);
                    var s_ArrDate = $(".start_date").attr("data-time");//入店时间
                    var s_DepDate = $(".end_date").attr("data-time");//离店时间
                    var arr1 = s_ArrDate.split("-");
                    var arr2 = s_DepDate.split("-");                
                    $(".h5_date_in span").eq(0).html(arr1[1] + "月" + arr1[2] + "日");
                    $(".h5_date_out span").eq(0).html(arr2[1] + "月" + arr2[2] + "日");
                    var weekDay = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
                    var check_in = new Date(Date.parse(s_ArrDate.replace(/-/g, "/")));
                    var check_out = new Date(Date.parse(s_DepDate.replace(/-/g, "/")));
                    $(".h5_date_in span").eq(1).html(weekDay[check_in.getDay()] + "入住");
                    $(".h5_date_out span").eq(1).html(weekDay[check_out.getDay()] + "离店");
                    $("#h5_date_b .h5_date_in span").eq(1).html(weekDay[check_in.getDay()] + "入住");
                    $("#h5_date_b .h5_date_out span").eq(1).html(weekDay[check_out.getDay()] + "离店");
                    var days = DateDiffH5(s_ArrDate, s_DepDate); //入住几晚

                    $("input[name='begdate']").val(s_ArrDate);
                    $("input[name='enddate']").val(s_DepDate);
                    $(".enter_time .total").html(days);                   
                    $("#beginDate").val(s_ArrDate);
                    $("#endDate").val(s_DepDate);
                    $('#h5_date').html($('#h5_date_b').html())
                    $('#h5_mask').hide();
                    $.cookie("delete", {
                        name: 'dateCookie'
                    });
                    $.cookie("set", {
                        duration: 0.1,
                        name: 'dateCookie',
                        value: $("#beginDate").val() + $("#endDate").val()
                    });
                    loadRoomTypeList_h5();
                }
            });
       // }

       
        
    })

    /*==============================================================/日期控件================================*/

   
   
    var timer_c=null;
    var iNow_c = 0;
    var banner_src = $('.h5_hotelDetial .swiper-wrapper .swiper-slide').eq(1).find('img').attr('_src')
    $('.h5_hotelDetial .swiper-wrapper .swiper-slide').eq(1).find('img').attr('src', banner_src);
    $('.h5_hotelDetial .swiper-wrapper .swiper-slide').eq(1).find('img').load(function () {
       
    })
    timer_c=setInterval(function(){               
        if (iNow_c == 10) {
            clearInterval(timer_c)
        };
        var banner_src_a = $('.h5_hotelDetial .swiper-wrapper .swiper-slide').eq(iNow_c).find('img').attr('_src')
        $('.h5_hotelDetial .swiper-wrapper .swiper-slide').eq(iNow_c).find('img').attr('src',banner_src_a);
        iNow_c++;
    },500)
    


    //时租房 与 今夜特惠切换
    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }
    var arg_tab = GetQueryString('ActivityCode')
    if (arg_tab == 'ST' || arg_tab == 'YT') {
        $('#h5_date').addClass('flag');
        $('.limit_today').removeClass('flag');
    } else {
        $('.limit_today').addClass('flag');
        $('#h5_date').removeClass('flag');
    }
    

});

/*=================================详情页====================================*/
//根据不同屏幕尺寸，调用页面;


function viewWidth() {
    if ($(window).width() > 1000) {
       // console.log(1111)
        $('.main_pc').css('display', 'block');
        $('#h5Main').css('display', 'none');       
        $('body').css({ 'background': "#fff", 'overflow': 'auto' });
        $('html').css('height', 'auto');
    } else {
       // console.log(222)
        $('.main_pc').css('display', 'none');
        $('#h5Main').css('display', 'block');
        $('.h5_logo').css({ 'opacity': '0.85', 'filter': 'alpha(opacity=85)' })
        $('html').css('height', 100+'%')
        img_top_H();
        img_H();

        
    };
};

//轮播图不存在时，使用默认图片;
function error_img(obj, arr) {
    obj.each(function (i, elem) {
        $(this).error(function () {
            $(this).attr('src', "https://images.bthhotels.com/image/webH5/public.png");
            arr[i] = "https://images.bthhotels.com/image/webH5/public.png"
        })
    })
};

//房型信息
function roomInfo() {
    $('.list_box').click(function () {
        
        $('#h5_mask').hide();
        $('.h5_tel_b').css('display', 'block');//浮层;
        $('#wrappera').css('display', 'block');

        var oDiv = $('<div class="h5_oDiv">');
        oDiv.html(' <h3 class="fix">\
						<span class="alert_sp1 fl">'+ $(this).find('h3 p em').html() + '</span>\
						<span class="alert_sp2 iconfont fr">&#xe73e;</span>\
				</h3>\
                <div class="not_found" ><div class="img" style="background-image:url('+ $(this).find(".h5_fl").attr("data-src")+')"></div ></div >\
					<ul class="alert_ul">\
						<li class="fix">\
							<span class="li_sp_fl fl">床宽</span>\
							<span class="li_sp_rg fr">' + $(this).find('.h5_middle p span').eq(1).html() + '</span>\
						</li>\
						<li class="fix">\
						<span class="li_sp_fl fl">入住</span>\
						<span class="li_sp_rg fr">' + $(this).find('.h5_middle p span').eq(2).html() + '</span>\
						</li>\
						<li class="fix">\
						<span class="li_sp_fl fl">面积</span>\
						<span class="li_sp_rg fr"> ' + $(this).find('.h5_middle p span').eq(3).html() + '</span>\
				</li>\
                <li class="fix">\
					<span class="li_sp_fl fl">窗户</span>\
					<span class="li_sp_rg fr"> ' + $(this).find('.h5_middle p span').eq(4).html() + '</span>\
				</li>\
              <li class= "fix">\
                    <span class="li_sp_fl fl">其他</span>\
                    <span class="li_sp_rg fr">'+ $(this).find('.h5_middle p span').eq(5).html() +'</span>\
				</li >\
                <li class= "fix">\
                    <span class="li_sp_fl fl">设施</span>\
                    <span class="li_sp_rg fr">'+ $(this).find('.h5_middle p span').eq(6).html() +'</span>\
				</li >\
                <li class="fix">\
					<span class="li_sp_fl fl">备注</span>\
					<span class="li_sp_rg fr">'+ $(this).find('.h5_middle p span').eq(7).html() +'</span>\
				</li></ul > ');
        
        $('#wrappera #scroller').append(oDiv);
        
        //图片弹框顶部字体为arial字体
        $('.alert_ul li span').each(function (i, elem) {
            $(this).html($(this).html().replace(/[0-9.-]+/g, function (arr0) {
                return "<span class='h5_arial'> " + arr0 + " </span>";
            }))
        })

        //关闭弹框;
        $('.alert_sp2').click(function () {
            $('.h5_tel_b').css('display', 'none');//浮层
            $('.h5_oDiv').remove();
            $('#wrappera').css('display', 'none');
        });

        //点击浮层关闭弹框
        $('.h5_tel_b').click(function () {
            $('.h5_tel_b').css('display', 'none');//浮层
            $('.h5_oDiv').remove();
            $('#wrappera').css('display', 'none');
        });

    });
}//房型信息弹框结束

 //时租房
function loadRoomTypeList_h5_ST(hotelCdVal) {

    var params = { 
        hotelCd: hotelCdVal
    }
        //时租房
        $(".h5_hotelDetial .h5_list").load("/HotelAct/RoomList_H5_ST", params, function (data) {
            //加载效果
            $('#h5_mask').hide();
            // console.log(data)
            //房型信息
            roomInfo();
            //只用一个内容的是居中
            $(".h5_hotelDetial .h5_list>li").css({ paddingBottom: 0 });
            $(".h5_hotelDetial .h5_li_fast").css({padding:'2px 12px'}).find(".h5_more_fl").css({marginTop:'8px'});
            $(".h5_hotelDetial .h5_more").show().css({ marginTop: '10px' }).find(".h5_money").css({textAlign:'right'});
        });
}

//房型信息数据请求
function loadRoomTypeList_h5() {

    if ($("#ActivityCode").val() == "ST") { 
        loadRoomTypeList_h5_ST($('#hotelCd').val())
        return;
    }

    var memberNo = $("#MemberNo").val();
    var params = {
        ArrDate: $("#beginDate").val(),
        DepDate: $("#endDate").val(),
        hotelCd: $('#hotelCd').val(),
        memberNo: memberNo,
        ForHighLevel: $("#ForHighLevel").val()
    }
    if ($.cookie("exist", { name: 'dateCookie' })) {
        var dateCookie = $.cookie("get", {
            name: 'dateCookie'
        }).replace(/\//g, '-')
        var startDate = dateCookie.substr(0, 10)
        var endDate = dateCookie.substr(10)
        
        params.ArrDate=startDate
        params.DepDate=endDate
    }
     
        //console.log(params)
        $(".h5_hotelDetial .h5_list").load("/HotelAct/RoomList_H5", params, function (data) {
            $('#h5_mask').hide();
            // console.log(data)
            //图片懒加载
            var aImg = $('.h5_details .h5_list>li');
            aImgLoad()
            $('.h5_details').on("scroll", aImgLoad)
            function aImgLoad() {
                aImg.each(function (index, element) {
                    var scrollTop = $('.h5_details').scrollTop();
                    var clientH = $('.h5_details').height();
                    var Dom_H = $(element).height();
                    var imgTop = Dom_H * index;
                    if ($('.h5_details .h5_text').css('display') == "none") {
                        clientH = $('.h5_details').height() - (46 * 4 + 11 + $('.h5_hotelDetial .swiper-container').height())
                    } else {
                        clientH = $('.h5_details').height() - (46 * 5 + 11 + $('.h5_hotelDetial .swiper-container').height())
                    }

                    if (scrollTop + clientH > imgTop) {

                        $(element).find('.h5_fl img').attr("src", $(element).find('.h5_fl img').attr("_src"));
                    }
                })
            };

            //酒店详情
            $('.h5_list li div.h5_fr').toggle(function () {
                $(this).find('.h5_zhan').html('&#xe6b3;');
                $(this).parents('li').css('paddingBottom', 0);
                $(this).next().css('marginTop', 10);
                $(this).siblings('.h5_more').css({ "display": "block", });
                if ($(this).siblings('.h5_more').find('ul').children().length > 3) {
                    $(this).siblings('.h5_more').find('ul li:gt(2)').hide();
                    $(this).siblings('.h5_more').find('.h5_residue').children().eq(0).html('查看剩余<strong class="h5_arial">' + ($(this).siblings(".h5_more").find('ul>li').length - 3) + '</strong>个价格');
                } else {
                    $(this).siblings('.h5_more').find('.h5_residue').css("display", "none");
                }
            }, function () {
                $(this).parents('li').css('paddingBottom', 10);
                $(this).next().css('marginTop', 0);
                $(this).find('.h5_zhan').html('&#xe6b4;')
                $(this).siblings('.h5_more').css({ "display": "none", })
            });

            //剩余价格
            $('.h5_details .h5_residue').toggle(function () {
                $(this).prev().find('li:gt(2)').show();
                $(this).children().eq(0).html('收起剩余价格')
                $(this).children('.h5_down').html('&#xe64b;')
                $(this).prev().animate({ "height": 100 + '%' }, 0);

            }, function () {
                $(this).children().eq(0).html('查看剩余<strong class="h5_arial">' + ($(this).prev().find('li').length - 3) + '</strong>个价格')
                $(this).children('.h5_down').html('&#xe665;')
                $(this).prev().animate({ "height": 222 }, 0);
            });
            
            //房型信息
            roomInfo();

            //评分
            var constant = 5;
            var fen_val = $('.h5_hotelDetial .h5_start strong.h5_score').html();
            var percentage = parseInt(fen_val / constant * 100)
            $('.h5_hotelDetial .h5_start div.icon_active').width(percentage + "%");

            //无早没有隐藏空标签
            if ($('.h5_hotelDetial .h5_li_fast .h5_more_fl p').length != 0) {
                if ($('.h5_hotelDetial .h5_li_fast .h5_more_fl p').html() == " &nbsp;") {
                    $('.h5_hotelDetial .h5_li_fast .h5_more_fl p').hide();
                };
            };

            //让没有早餐是内容居中
            $('.h5_hotelDetial .h5_li_fast .h5_more_fl').each(function (i, elem) {
                if ($(elem).children().length == 2 || $(elem).children().eq(1).html() == " &nbsp;") {
                    $(elem).css('paddingTop', 5)
                }
            });

            //只用一个内容的是居中
            $('.h5_hotelDetial .h5_li_fast .h5_more_fl').each(function (i, elem) {
                if ($(elem).children().length == 3 || ($(elem).children().eq(1).html() == " &nbsp;" && $(elem).children().eq(2).html() == " ")) {
                    $(elem).css('paddingTop', 18)
                }
                if ($(elem).children().length == 2 || $(elem).children().eq(1).html() == " ") {
                    $(elem).css('paddingTop', 18)
                }
            });
        }); 
  
};

//图片自适应

function img_top_H() {
    var aLi_W = $('.h5_hotelDetial .swiper-wrapper .swiper-slide').width();   
    var scale = aLi_W / 750
    var aLi_H = scale * 500;

    //console.log(aLi_W)
    // var aLi_H = $('.h5_hotelImg .h5_img ul li').height(); 
    $('.h5_hotelDetial .swiper-wrapper .swiper-slide').width(aLi_W);
    $('.h5_hotelDetial .swiper-wrapper .swiper-slide').height(aLi_H);
    $('.h5_hotelDetial .swiper-wrapper').height(aLi_H);
    $('.h5_hotelDetial .swiper-wrapper .swiper-slide img').height(aLi_H);
    $('.h5_hotelDetial .swiper-wrapper .swiper-slide img').width(100 + "%");
    
}

/*=================================/详情页====================================*/

/*======================================图片情页信息================================*/
//图片详情自适应
img_H()
function img_H() {
    //var aLi_W = $('.h5_hotelImg .h5_img ul li').width();
    var aLi_W = ($('#wrapper').width() - 34) * 0.4853333;
    var scale = aLi_W / 750
    var aLi_H = scale * 500;
    // var aLi_H = $('.h5_hotelImg .h5_img ul li').height();       
    $('.h5_hotelImg .h5_img ul li img').height(aLi_H);
    $('.h5_hotelImg .h5_img ul li img').width(aLi_W)
};
/*======================================/图片情页信息================================*/
/*=====================================用户点评================================*/
//判断是pc端访问还是移动端访问
var count = 1
var comment_flag = true;
function browserRedirect() {
    var sUserAgent = navigator.userAgent.toLowerCase();
    var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
    var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
    var bIsMidp = sUserAgent.match(/midp/i) == "midp";
    var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
    var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
    var bIsAndroid = sUserAgent.match(/android/i) == "android";
    var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
    var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
    if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
        $('.h5_mark .h5_fl span:gt(4)').hide();
        //alert('手机端访问');
        $('#com_box').scroll(function () {
            if ($('#com_box').scrollTop() + $(window).height() - 63 >= ($('.h5_hotel_list ').height())) {
                if (comment_flag) {
                    $('#h5_mask').show();
                    loading_hide()//loading图隐藏;
                    count++;
                    loadRecomments_a(count)
                }              
            }
        })
    } else {
       
        //alert('电脑端访问');
        $('#com_box').scroll(function () {
           $('body').css({ 'fontFamily': 'Microsoft YaHei'});
            $('.h5_mark .h5_fl span:gt(4)').show();
            //console.log($('#com_box').scrollTop());
            //console.log($(window).height());
            //console.log($('.h5_hotel_list ').height());
            if ($('#com_box').scrollTop() + $(window).height() - 133 >= ($('.h5_hotel_list ').height())) {
                if (comment_flag) {
                    $('#h5_mask').show();
                    loading_hide()//loading图隐藏;
                    count++;
                    loadRecomments_a(count)
                }
               
            }
        })
    }
};

function loadRecomments_a(pageIndex) {
    var parms = {
        hotelcd: $("#hotelCd").val(),
        pageNo: pageIndex,
        forH5Page: true,
    };
    $.ajax({
        type: "GET",
        url: "/HotelAct/dianping",
        data: parms,
        success: function (result) {
            $('#h5_mask').hide();
            $("#thelist").append(result);
            if ($("#thelist li").length % 10 != 0) {
                $('#pullUp span').eq(0).html('&#xe6c7;')
                $('#pullUp span').eq(1).html('没有数据了');
                comment_flag = false;
            } else {
                $('#pullUp span').eq(0).html('&#xe6c5;')
                $('#pullUp span').eq(1).html('更多数据加载中...');
            }

        },
        error: function () {
            //console.log('请求数据异常')
        }
    })
};
/*=====================================/用户点评================================*/



